const merge = (A, m, B, n) => {
  for (let i = m; i < m + n; i++) {
    A[i] = B[i - m]
  }
  return A.sort((a, b) => a - b)
}

console.log(merge([1, 2, 3, 0, 0, 0], 3, [2, 5, 6], 3));